package cn.edu.tju.se.base.service;
import java.io.File;

/**
 * Created by williezz on 2016/3/13.
 */
public class FileManager {
    public void deleteAll(File file){

        if(file.isFile() || file.list().length ==0)
        {
            file.delete();
        }else{
            File[] files = file.listFiles();
            for (int i = 0; i < files.length; i++) {
                deleteAll(files[i]);
                files[i].delete();
            }
        }
    }

    public void deleteDir(File file){

        if(file.isFile() || file.list().length ==0)
        {
            file.delete();
        }else{
            File[] files = file.listFiles();
            for (int i = 0; i < files.length; i++) {
                deleteAll(files[i]);
                files[i].delete();
            }
            file.delete();
        }
    }

    public static void main(String[] args){
        File f = new File("f:"+File.separator+"Config");
        FileManager test = new FileManager();
        test.deleteDir(f);
    }
}
